<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;

/**
 * @package App\Http\Controllers\Api
 * @see QuickController
 */
class QuickController extends BaseController
{

    /**
     * collect
     * @uri /quick/collect
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"url":"548CC1CF32C3B810","package_id":"E84CAA99F50DEC7D"}
     * @response {"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6587\u7ae0ID","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u6458\u8981\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c","cover_url":"\u5c01\u9762\u56fe\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c"},"message":"OK"}
     */
    public function collect(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"id":"24\u4f4d\u6587\u7ae0ID","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u6458\u8981\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c","cover_url":"\u5c01\u9762\u56fe\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c"},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * preview
     * @uri /quick/preview
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"url":"59A5ABC5BD336F25"}
     * @response {"success":true,"statusCode":200,"result":{"title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u6458\u8981\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c","cover_url":"\u5c01\u9762\u56fe\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c"},"message":"OK"}
     */
    public function preview(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u6458\u8981\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c","cover_url":"\u5c01\u9762\u56fe\uff0c\u53ef\u80fd\u4f4d\u7a7a\u503c"},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

}